<?php 
$this->load->view('admin/layout/head', array('title'=>'专车接送', 'nav' => 'user'), FALSE);
?>

<div id="container">
	
	<div class="table-container mt-10">
		<table class="table table-bordered table-striped table-hover scroll-table">
			<thead >
				<tr>
					<th width="60" class="text-center">编号</th>
					<th  class="text-center">姓名</th>
					<th  class="text-center">电话</th>
					<th  class="text-center">接送日期</th>
					<th class="text-center">地址</th>
					<th class="text-center">提交时间</th>
					<th width="120" class="text-center">操作</th>
				</tr>
			</thead>
			<tbody class="text-center">
				<?php 
				foreach ($cars as $u) {
				?>
				<tr>
					<td><?php echo $u['id'] ?></td>
					<td><?php echo $u['name'] ?></td>
					<td><?php echo $u['phone'] ?></td>
					<td><?php echo $u['date'] ?></td>
					<td><?php echo $u['address'] ?></td>
					<td><?php echo $u['create_time'] ?></td>
					<td>
						<?php if($u['status'] == 0): ?>
							<a href="javascript:;" class="modify-btn" cid="<?php echo $u['id'] ?>">未接送</a> 
						<?php else: ?>
							<span>已接送</span>
						<?php endif; ?>
						<a href="javascript:;" class="del-btn" cid="<?php echo $u['id'] ?>">删除</a>			
					</td>
				</tr>
				<?php
				}
				?>
				
			</tbody>
			<?php 
			if($cars->last_page>1){
			?>
			<tfoot>
				<td colspan="9" style="text-align:right">
					<?php echo $cars->render() ?>
				</td>
			</tfoot>
			<?php 
			}
			?>
			
		</table>
	</div>
</div>

<?php 
$this->load->view('admin/layout/footer');
?>

<script type="text/javascript">
	$(function(){
		//删除
		$('.del-btn').on('click',function(){
			var cid = $(this).attr('cid');
			confirm('确定要删除此申请吗？',function(e){
				if(e.index == 1){
					$.post('/admin/car/delete', {id: cid}, function(data, textStatus, xhr) {
						alert('删除成功！');
						window.location.reload();
					});
				}
			})
			
		})

		//删除
		$('.modify-btn').on('click',function(){
			var cid = $(this).attr('cid');
			confirm('确定要设置未已接送状态吗？',function(e){
				if(e.index == 1){
					$.post('/admin/car/status', {id: cid}, function(data, textStatus, xhr) {
						alert('设置成功！');
						window.location.reload();
					});
				}
			})
			
		})
	})
</script>















